import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UpdateServlet extends HttpServlet{
	public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
	{
		
		String str1=req.getParameter("id");
		String str2=req.getParameter("Loptop");
		String str3=req.getParameter("Cost");
		
		int pid=Integer.parseInt(str1.trim());
		int pcost=Integer.parseInt(str3.trim());
		
		HibernateDao hd=new HibernateDao();
		boolean b=hd.update(pid, str2,pcost);
		res.setContentType("text/html");
		PrintWriter pw=res.getWriter();
		
		if(b==true)
		{
			pw.println("<h1>record are updated</h1>");
		}
		else
		{
			pw.println("<h1>failed to update</h1>");
			pw.println("<a href='profile.html'>HOME</a>");
		}pw.println("<a href='profile.html'>HOME</a>");
	}
	}